package com.zzh.zzhaiagent.domain.vo;

import com.zzh.zzhaiagent.domain.entity.UserProfiles;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author zzh
 * @since 2025-05-07
 * 用户敏感过滤信息 (密码)
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class UserProfilesVO implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键ID
     */
    private Long id;

    /**
     * 姓名
     */
    private String name;

    /**
     * 头像
     */
    private String avatar;

    /**
     * 年龄
     */
    private Integer age;

    /**
     * 职业
     */
    private String occupation;

    /**
     * 性别
     */
    private String gender;

    /**
     * 手机号
     */
    private String phone;

    /**
     * 爱好
     */
    private List<String> hobbies;

    /**
     * 账户
     */
    private String userAccount;


    /**
     * 邮箱
     */
    private String email;

    /**
     * token (这个token是用户的AI能服务的token)
     */
    private Long token;

    /**
     * 个人简介
     */
    private String profile;

    //构建器
    public static UserProfilesVO builderDBToVO(UserProfiles userProfiles) {
        UserProfilesVO userProfilesVO = new UserProfilesVO();
        userProfilesVO.setId(userProfiles.getId());
        userProfilesVO.setName(userProfiles.getName());
        userProfilesVO.setAge(userProfiles.getAge());
        userProfilesVO.setOccupation(userProfiles.getOccupation());
        userProfilesVO.setGender(userProfiles.getGender());
        userProfilesVO.setPhone(userProfiles.getPhone());
        String hbDB = userProfiles.getHobbies();
        if (hbDB != null){
            String[] split = hbDB.split(",");
            userProfilesVO.setHobbies(List.of(split));
        }
        userProfilesVO.setUserAccount(userProfiles.getUserAccount());
        userProfilesVO.setEmail(userProfiles.getEmail());
        userProfilesVO.setToken(userProfiles.getToken());
        userProfilesVO.setProfile(userProfiles.getProfile());
        userProfilesVO.setAvatar(userProfiles.getAvatar());
        return userProfilesVO;
    }


}
